package yyee.llee.mmee.viewmode

import yyee.llee.mmee.base_api_net.base_api_bean.bean.AirCityInfoBean
import yyee.llee.mmee.base_api_net.base_api_bean.bean.AirCityQuality
import yyee.llee.mmee.base_api_net.base_api_bean.bean.BaseResult
import yyee.llee.mmee.weather.base.BaseRepository

/**
 * Created by Lingbaeryi
 */
class AirRepository : BaseRepository() {

    suspend fun getAirNow(city: String): BaseResult<ArrayList<AirCityInfoBean>> {
        return safeApiCall(call = { requestAirNow(city) }, errorMessage = "网络错误")
    }

    private suspend fun requestAirNow(city: String): BaseResult<ArrayList<AirCityInfoBean>> {
        return executeResponseForJH(mApiManager.getAirNow(city))
    }

    suspend fun getAirDay(city: String): BaseResult<ArrayList<AirCityQuality>> {
        return safeApiCall(call = { requestAirDay(city) }, errorMessage = "网络错误")
    }

    private suspend fun requestAirDay(city: String): BaseResult<ArrayList<AirCityQuality>> {
        return executeResponseForJH(mApiManager.getAirDay(city))
    }


}